/* 
 * File:   ParticleSystemManager.h
 * Author: RedEyedKiller
 *
 * Created on 20 Αύγουστος 2010, 8:07 μμ
 */

#ifndef PARTICLESYSTEMMANAGER_H
#define	PARTICLESYSTEMMANAGER_H

#include <string>
#include "ParticleSystem.h"
#include "../RenderingManager.h"
#include "Force.h"

namespace physicsSystem
{

namespace particleSystem
{
/**
 * This class stores all required data for particles and provides an interface to
 * manipulate Particles Systems.
 *
 * PhysicsManager encapsulates this class and this should not be used alone.
 */
class ParticleSystemManager
{
public:
    ParticleSystemManager();
    ~ParticleSystemManager();
    
    /**
     * Loads requested particle system.
     * @param name the name of the system. (filename excluding the .xml extension)
     * @param active specify if the new system should be active or not.
     * @return A pointer to the drawable interface of new system in order to register it
     *         into the appropirate rendering layer.
     */
    Drawable* LoadParticleSystem(const std::string &name, bool active = true);
    
    /**
     * Returns true if specified particle system is loaded.
     * @param name - the name of the system
     * @return 
     */
    bool IsParticleSystemLoaded(const std::string &name);

    /**
     * Removes the specified system from the manager.
     * @param name The system name.
     */
    void DeleteParticleSystem(const std::string &name);

    /**
     * The specified system will stop render and update itself until it is activated again.
     * @param name The system name.
     */
    void HideParticleSystem(const std::string &name);

     /**
     * Activates the specified system making it updatable and visible.
     * @param name The system name.
     */
    void ActivateParticleSystem(const std::string &name);

    /**
     * Returns the specified particle system.
     * @param name The system to return.
     * @return The system.
     */
    ParticleSystem* GetParticleSystem(const std::string &name);
    
    /**
     * Removes all systems.
     */
    void ClearParticleSystems();

    void SetParticleUpdateTime(int updateTime);
    int GetParticleUpdateTime() const;
 
protected:
    /**
     * The main method which invokes all per frame particle logic.
     * @param deltaTime The time passed since last update.
     */
    void UpdateParticles(unsigned long  deltaTime,LevelMap* map);
    int particlesUpdateTime;
    typedef std::map<std::string,ParticleSystem*> ParticleSystemPool;
    ParticleSystemPool systems;
};

};
};

#endif	/* PARTICLESYSTEMMANAGER_H */

